package br.usp.icmc.biomac.shared;

/**
 * Internal class to keep message details.
 *
 * @author amsnyder
 */
public class Message {

    int timeMs;
    MessageLevel level;
    String message;

    public Message(int elapsedMs, MessageLevel level, String message){
        this.timeMs=elapsedMs;
        this.level=level;
        this.message = message;
    }

    public boolean isDebug(){
        return level == MessageLevel.DEBUG;
    }

    @Override
    public String toString(){
        String step="init";
        StringBuilder sb = new StringBuilder();
        try{
            sb.append(timeMs);
            sb.append(" ms, ");
            sb.append(level.name());
            sb.append(", ");
            sb.append(message);

        return sb.toString();
        }catch(Exception e){
            return "Message.toString exp @"+step+":: "+sb.toString();
        }
    }
}

